using SS;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace TVSGPP.func
{
	public class frmSearchBillOutputRetail : Form
	{
		private IContainer components = null;
		private GroupBox groupBox1;
		private Label label1;
		private TextBox txtBillID;
		private TextBox txtProductName;
		private Label label2;
		private Label label5;
		private Button btnSearch;
		private Button btnClose;
		private TextBox txtPacket;
		private Label label3;
		private TextBox txtCusName;
		private Func objFunc = new Func();
		public string tmpStrConnection = "";
		public string sql_Search = "";
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.groupBox1 = new GroupBox();
			this.txtCusName = new TextBox();
			this.txtPacket = new TextBox();
			this.label3 = new Label();
			this.label5 = new Label();
			this.txtProductName = new TextBox();
			this.label2 = new Label();
			this.txtBillID = new TextBox();
			this.label1 = new Label();
			this.btnSearch = new Button();
			this.btnClose = new Button();
			this.groupBox1.SuspendLayout();
			base.SuspendLayout();
			this.groupBox1.Controls.Add(this.txtCusName);
			this.groupBox1.Controls.Add(this.txtPacket);
			this.groupBox1.Controls.Add(this.label3);
			this.groupBox1.Controls.Add(this.label5);
			this.groupBox1.Controls.Add(this.txtProductName);
			this.groupBox1.Controls.Add(this.label2);
			this.groupBox1.Controls.Add(this.txtBillID);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Location = new Point(12, 12);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new Size(460, 128);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Thông tin tìm kiếm";
			this.txtCusName.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtCusName.Location = new Point(114, 85);
			this.txtCusName.Name = "txtCusName";
			this.txtCusName.Size = new Size(332, 22);
			this.txtCusName.TabIndex = 3;
			this.txtCusName.KeyPress += new KeyPressEventHandler(this.txtCusName_KeyPress);
			this.txtPacket.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtPacket.Location = new Point(302, 26);
			this.txtPacket.Name = "txtPacket";
			this.txtPacket.Size = new Size(144, 22);
			this.txtPacket.TabIndex = 2;
			this.txtPacket.KeyPress += new KeyPressEventHandler(this.txtPacket_KeyPress);
			this.label3.AutoSize = true;
			this.label3.Location = new Point(230, 29);
			this.label3.Name = "label3";
			this.label3.Size = new Size(68, 15);
			this.label3.TabIndex = 13;
			this.label3.Text = "Số hiệu lô :";
			this.label5.AutoSize = true;
			this.label5.Location = new Point(31, 88);
			this.label5.Name = "label5";
			this.label5.Size = new Size(79, 15);
			this.label5.TabIndex = 12;
			this.label5.Text = "Khách hàng :";
			this.txtProductName.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtProductName.Location = new Point(114, 56);
			this.txtProductName.Name = "txtProductName";
			this.txtProductName.Size = new Size(332, 22);
			this.txtProductName.TabIndex = 0;
			this.txtProductName.KeyPress += new KeyPressEventHandler(this.txtProductName_KeyPress);
			this.label2.AutoSize = true;
			this.label2.Location = new Point(17, 59);
			this.label2.Name = "label2";
			this.label2.Size = new Size(93, 15);
			this.label2.TabIndex = 2;
			this.label2.Text = "Tên sản phẩm :";
			this.txtBillID.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.txtBillID.Location = new Point(114, 26);
			this.txtBillID.Name = "txtBillID";
			this.txtBillID.Size = new Size(112, 22);
			this.txtBillID.TabIndex = 1;
			this.txtBillID.KeyPress += new KeyPressEventHandler(this.txtBillID_KeyPress);
			this.label1.AutoSize = true;
			this.label1.Location = new Point(26, 29);
			this.label1.Name = "label1";
			this.label1.Size = new Size(84, 15);
			this.label1.TabIndex = 0;
			this.label1.Text = "Số đơn hàng :";
			this.btnSearch.FlatStyle = FlatStyle.System;
			this.btnSearch.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnSearch.Location = new Point(286, 148);
			this.btnSearch.Name = "btnSearch";
			this.btnSearch.Size = new Size(90, 30);
			this.btnSearch.TabIndex = 4;
			this.btnSearch.Text = "Tìm kiếm";
			this.btnSearch.UseVisualStyleBackColor = true;
			this.btnSearch.Click += new EventHandler(this.btnSearch_Click);
			this.btnClose.FlatStyle = FlatStyle.System;
			this.btnClose.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnClose.Location = new Point(382, 148);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new Size(90, 30);
			this.btnClose.TabIndex = 5;
			this.btnClose.Text = "Thoát [ESC]";
			this.btnClose.UseVisualStyleBackColor = true;
			this.btnClose.Click += new EventHandler(this.btnClose_Click);
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new Size(484, 186);
			base.Controls.Add(this.btnClose);
			base.Controls.Add(this.btnSearch);
			base.Controls.Add(this.groupBox1);
			this.Cursor = Cursors.Hand;
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			base.KeyPreview = true;
			this.MaximumSize = new Size(500, 220);
			this.MinimumSize = new Size(500, 220);
			base.Name = "frmSearchBillOutputRetail";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = " ..: TÌM KIẾM";
			base.Load += new EventHandler(this.frmSearchBill_Load);
			base.KeyDown += new KeyEventHandler(this.frmSearchBill_KeyDown);
			this.groupBox1.ResumeLayout(false);
			this.groupBox1.PerformLayout();
			base.ResumeLayout(false);
		}
		public frmSearchBillOutputRetail()
		{
			this.InitializeComponent();
			this.tmpStrConnection = this.objFunc.strConnectionString;
		}
		private void frmSearchBill_Load(object sender, EventArgs e)
		{
			this.txtProductName.Focus();
		}
		private void btnClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void btnSearch_Click(object sender, EventArgs e)
		{
			this.sql_Search = "SELECT DISTINCT [TabBill].[ID], [TabBill].[_DoctorName], [TabBill].[_DoctorAddress],[TabBill].[_DoctorPhone], [TabBill].[_DoctorDesease],[TabBill].[_CusFreeID], [TabBill].[CreateDate], [TabBill].[TotalMoney],[TabBill].[_Name],[TabBill].[_Address],[TabBill].[_Age],[TabBill].[_Sex],[TabBill].[_Phone], [TabBill].[TypeInput], [TabBill].[WID], [TabBill].[Note], [TabBill].[PID], [TabBill].[userName], [TabBill].[Printed], [TabBill].[Discount] FROM [TabBill],[TabDetailBill] WHERE [TabBill].[ID] = [TabDetailBill].[BillID] AND [TabBill].[TypeInput] = 'OUT4'";
			if (this.txtBillID.Text != "")
			{
				this.sql_Search = this.sql_Search + " AND ([TabBill].[ID] = '" + this.txtBillID.Text + "'";
			}
			else
			{
				this.sql_Search += " AND (1 = 1";
			}
			if (this.txtPacket.Text != "")
			{
				this.sql_Search = this.sql_Search + " AND UPPER([TabDetailBill].[Packet]) = '" + this.txtPacket.Text.ToUpper() + "'";
			}
			else
			{
				this.sql_Search += " AND 1 = 1";
			}
			if (this.txtProductName.Text != "")
			{
				this.sql_Search = this.sql_Search + " AND [TabDetailBill].[productName] LIKE N'%" + this.txtProductName.Text + "%'";
			}
			else
			{
				this.sql_Search += " AND 1 = 1";
			}
			if (this.txtCusName.Text.Trim() != "")
			{
				this.sql_Search = this.sql_Search + " AND [TabBill].[_Name] LIKE N'%" + this.txtCusName.Text + "%')";
			}
			else
			{
				this.sql_Search += " AND 1 = 1)";
			}
			if (this.txtBillID.Text.Trim() != "" || this.txtProductName.Text.Trim() != "" || this.txtCusName.Text.Trim() != "" || this.txtPacket.Text.Trim() != "")
			{
				base.Close();
			}
			else
			{
				MessageBox.Show("Bạn chưa cung cấp thông tin cần tìm kiếm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
		}
		private void txtBillID_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtPacket.Focus();
			}
		}
		private void txtProductName_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtCusName.Focus();
			}
		}
		private void cbbProvider_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.btnSearch.PerformClick();
			}
		}
		private void txtPacket_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.txtProductName.Focus();
			}
		}
		private void frmSearchBill_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				base.Close();
			}
		}
		private void txtCusName_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				this.btnSearch.PerformClick();
			}
		}
	}
}
